package com.example.dem7;

/**
 * @program: xian-cheng
 * @description:
 * @author: 诸葛龙辰
 * @create: 2022-11-01 20:00
 **/
public class TestDog {
    public static void main(String[] args) {
        DogDemo d1 = new DogDemo();
        DogDemo d2 = new DogDemo();
        d1.start();
        d2.start();
    }
}
class DogDemo extends Thread{
    @Override
    public void run(){
        for (int i = 0; i <20 ; i++) {
            //当前线程放弃时间片，进入就绪状态，参与下次cpu时间片的竞争。 可能出现交替的频率比较高
            Thread.yield();
            System.out.println(Thread.currentThread().getName()+"#$%^&******"+i);
        }

    }
}